<template>
  <div class="cart">
    <nav-bar class="nav-bar">
      <div slot="center">购物车({{ length }})</div>
    </nav-bar>
    <cart-list></cart-list>
    <cart-bottom-bar></cart-bottom-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar.vue";
import CartList from "./childrenComps/CartList.vue";
import CartBottomBar from './childrenComps/CartBottomBar.vue';

import { mapGetters } from "vuex";

export default {
  name: "Cart",
  components: {
    NavBar,
    CartList,
    CartBottomBar,
  },
  computed: {
    // cartLength() {
    //   return this.$store.getters.cartLength
    // }
    //两种用法：
    // Mustache中同名
    // ...mapGetters(['cartLength','cartList'])
    // 不同名
    ...mapGetters({
      length: "cartLength",
    }),
  },
};
</script>
<style scoped>
  .nav-bar {
    background: var(--color-tint);
    color: #fff;
    font-weight: 700;
    z-index: 9;
  }
</style>